# Contributor: Łukasz Jendrysik <scadu@yandex.com>
# Contributor: Fabian Affolter <fabian@affolter-engineering.ch>
# Maintainer: Fabian Affolter <fabian@affolter-engineering.ch>
pkgname=nettle
pkgver=3.8
pkgrel=0
pkgdesc="A low-level cryptographic library"
url="https://www.lysator.liu.se/~nisse/nettle/"
arch="all"
license="LGPL-2.0-or-later"
depends_dev="gmp-dev"
makedepends="$depends_dev m4"
subpackages="$pkgname-static $pkgname-dev $pkgname-utils"
source="https://ftp.gnu.org/gnu/nettle/nettle-$pkgver.tar.gz"

# secfixes:
#   3.7.3-r0:
#     - CVE-2021-3580
#   3.7.2-r0:
#     - CVE-2021-20305

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--libdir=/usr/lib \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--localstatedir=/var \
		--enable-fat \
		--enable-shared \
		--disable-openssl \
		--enable-static
	make
	# strip comments in fields from .pc as it confuses pkgconf
	sed -i -e 's/ \#.*//' ./*.pc
}

check() {
	make -C examples  # required for rsa-encrypt
	make check
}

package() {
	make DESTDIR="$pkgdir" install
}

utils() {
	pkgdesc="Utils for nettle"
	mkdir -p "$subpkgdir"/usr
	mv "$pkgdir"/usr/bin "$subpkgdir"/usr/
}

sha512sums="
af3a910bd661ed9691b1bd66b0f8147aaebdc92ae6ab47640675df263409ecb8d25f0403fcc7dc6471264b9df0a47c025244404f0691ef58c133762f64b67610  nettle-3.8.tar.gz
"
